package com.ruoyi.web.controller.Tour;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TourFeedback;
import com.ruoyi.system.service.ITourFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 反馈管理Controller
 *
 * @author once
 * @date 2020-10-02
 */
@RestController
@RequestMapping("/Tour/feedback")
public class TourFeedbackController extends BaseController
{
    @Autowired
    private ITourFeedbackService tourFeedbackService;

    /**
     * 查询反馈管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(TourFeedback tourFeedback)
    {
        startPage();
        List<TourFeedback> list = tourFeedbackService.selectTourFeedbackList(tourFeedback);
        return getDataTable(list);
    }

    /**
     * 导出反馈管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:feedback:export')")
    @Log(title = "反馈管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TourFeedback tourFeedback)
    {
        List<TourFeedback> list = tourFeedbackService.selectTourFeedbackList(tourFeedback);
        ExcelUtil<TourFeedback> util = new ExcelUtil<TourFeedback>(TourFeedback.class);
        return util.exportExcel(list, "feedback");
    }

    /**
     * 获取反馈管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('Tour:feedback:query')")
    @GetMapping(value = "/{feedbackId}")
    public AjaxResult getInfo(@PathVariable("feedbackId") Long feedbackId)
    {
        return AjaxResult.success(tourFeedbackService.selectTourFeedbackById(feedbackId));
    }

    /**
     * 新增反馈管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:feedback:add')")
    @Log(title = "反馈管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourFeedback tourFeedback)
    {
        return toAjax(tourFeedbackService.insertTourFeedback(tourFeedback));
    }

    /**
     * 修改反馈管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:feedback:edit')")
    @Log(title = "反馈管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourFeedback tourFeedback)
    {
        return toAjax(tourFeedbackService.updateTourFeedback(tourFeedback));
    }

    /**
     * 删除反馈管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:feedback:remove')")
    @Log(title = "反馈管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feedbackIds}")
    public AjaxResult remove(@PathVariable Long[] feedbackIds)
    {
        return toAjax(tourFeedbackService.deleteTourFeedbackByIds(feedbackIds));
    }
}
